package com.itcrowd.ittao.service.data;

import java.util.ArrayList;

public class Price {
	public float mNumber;
	public MoneyType mType;
	
	public Price(float number, MoneyType type) {
		mNumber = number;
		mType = type;
	}
	
	public String toString() {
		return MoneyType.getDisplayString(mType)+"  "+mNumber;
	}
	
	public static ArrayList<Price> append(ArrayList<Price> list, Price price) {
		boolean find = false;
		for(Price p:list) {
			if(p.mType == price.mType) {
				p.mNumber += price.mNumber;
				find = true;
				break;
			}
		}
		if(!find) {
			list.add(price);
		}
		return list;
	}
	
	public static String getCostDisplayContent(ArrayList<Price> list) {
		StringBuilder sb = new StringBuilder();
		for(Price p : list) {
			sb.append(MoneyType.getDisplayString(p.mType)+":"+p.mNumber+"  ");
		}
		return sb.toString().trim();
	}
}
